package com.ctsi.sms.config;

import com.ctsi.sms.client.SmsClient;
import com.ctsi.sms.entity.SmsEntity;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class SmsClientFallbackFactory implements FallbackFactory<SmsClient> {
    private static final Logger logger = LoggerFactory.getLogger(SmsClientFallbackFactory.class);

    @Override
    public SmsClient create(Throwable cause) {
        return new SmsClient() {
            @Override
            public void sendSMS(SmsEntity smsEntity) {
                logger.error("sms client occur error: {}",cause);
            }
        };
    }
}
